# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=celery
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=5.5.2
pkgrel=1
pkgdesc='Distributed Asynchronous Task Queue (mingw-w64)'
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://docs.celeryq.dev/'
msys2_repository_url='https://github.com/celery/celery'
msys2_references=(
  'purl: pkg:pypi/celery'
)
license=('BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-billiard"
         "${MINGW_PACKAGE_PREFIX}-python-click-didyoumean"
         "${MINGW_PACKAGE_PREFIX}-python-click-plugins"
         "${MINGW_PACKAGE_PREFIX}-python-click-repl"
         "${MINGW_PACKAGE_PREFIX}-python-dateutil"
         "${MINGW_PACKAGE_PREFIX}-python-kombu"
         "${MINGW_PACKAGE_PREFIX}-python-pytz"
         "${MINGW_PACKAGE_PREFIX}-python-tzdata"
         "${MINGW_PACKAGE_PREFIX}-python-vine")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-cryptography: for celery.security"
            #"${MINGW_PACKAGE_PREFIX}-python-pymongo: for celery.backends.mongodb"
            "${MINGW_PACKAGE_PREFIX}-python-msgpack: for using the msgpack serializer"
            #"${MINGW_PACKAGE_PREFIX}-python-pyro: for using Pyro4 message transport"
            "${MINGW_PACKAGE_PREFIX}-python-redis: for celery.backends.redis"
            "${MINGW_PACKAGE_PREFIX}-python-sqlalchemy: for celery.backends.database"
            "${MINGW_PACKAGE_PREFIX}-python-boto3: for SQS transport"
            "${MINGW_PACKAGE_PREFIX}-python-yaml: for using the yaml serializer"
            "${MINGW_PACKAGE_PREFIX}-python-pyzmq: for using ZeroMQ transport")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('4d6930f354f9d29295425d7a37261245c74a32807c45d764bedc286afd0e724e')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "python-build-${MSYSTEM}"

  python -m pytest || true
}

package() {
  cd "python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
